package com.yz.Graph;

import javax.swing.*;

//使用GUI确认对话框控制循环
public class GuiText05 {

    public static void main(String[] args) {

        int sum =0;
        int option  = JOptionPane.YES_OPTION;
        while (option == JOptionPane.YES_OPTION){
            //如果一直选择yes，那么就会一直进行循环
            String num = JOptionPane.showInputDialog(null, "请输入一个你想输入的数字：");
            int data = Integer.parseInt(num);

            sum+=data;

            //记得重新赋值，要不然就不会退出循环
            option = JOptionPane.showConfirmDialog(null, "是否继续呢？");

        }
        JOptionPane.showMessageDialog(null,"最后的累加结果是："+sum);

    }
}
